/*
 * board.c
 *
 *  Created on: May 29, 2021
 *      Author: tau
 */
#include "board.h"
#include <pthread.h>


using namespace std;

static gpio* ledHeart;
static gpio* ledEvent;
static gpio* ledError;



gpio* beep;

gpio* getBeep(void){
	return beep;
}



void beepDiDi(void){
	beep->write(1);
	usleep(100000);
	beep->write(0);
	usleep(50000);
	beep->write(1);
	usleep(100000);
	beep->write(0);
}
static void gpioInit(void){
	ledHeart =  new gpio(0xcf,1);	//PG15
	ledEvent =  new gpio(0xcd,1);	//PG13
	ledError =  new gpio(0xce,1);	//PG14
	beep     =  new gpio(0x08,1);	//PA8
	beepDiDi();
}


void boardInit(void){
	gpioInit();
}



void onEvent(void){
	ledEvent->write(1);
	usleep(10000);
	ledEvent->write(0);
}
void onError(void){
	ledError->write(1);
	usleep(10000);
	ledError->write(0);
}
void onHeart(void){
	ledHeart->write(1);
	usleep(10000);
	ledHeart->write(0);
}



